<?php

abstract class Core_Model_Entity_Dynamic_Base extends Soul_Model_Entity_Base {    

    protected function initializeProperties() {
        $className = get_class($this);
        $className = substr($className, strpos($className, '_') + 1);
        $entity = App::getModel('system/dms_entity')->loadBy(array('class_name'=>$className));
        $properties = $entity->getDynamicProperties();
        foreach($properties as $property){
            switch ($property->getPropertyType()){
                case 'integer':
                    $pro = $this->createProperty($property->getName(), 'integer');
                    break;
                case 'string':
                    $pro = $this->createProperty($property->getName(), 'string');
                    break;
                case 'boolean':
                    $pro = $this->createProperty($property->getName(), 'boolean');
                    break; 
                case 'datetime':
                    $pro = $this->createProperty($property->getName(), 'datetime');
                    break; 
                case 'timestamp':
                    $pro = $this->createProperty($property->getName(), 'timestamp');
                    break;                
                case 'email':
                    $pro = $this->createProperty($property->getName(), 'email');
                    break; 
                case 'float':
                    $pro = $this->createProperty($property->getName(), 'float');
                    break; 
                case 'array':
                    $pro = $this->createProperty($property->getName(), 'array');
                    $pro->setItemCount($property->getItemCount());
                    break;
                default:
                    $pro = $this->createProperty($property->getName(), 'string');
                    break;                    
            }
            $pro->setIsIncrement($property->getIsIncrement())
                ->setIsPrimary($property->getIsPrimary())
                ->setInsertable($property->getInsertable())
                ->setUpdateable($property->getUpdateable())
                ->setLength($property->getLength())
                ->setRequired($property->getRequired())
                ->setDefaultValue($property->getDefaultValue())
                ->setLabel($property->getLabel())
                ->setDescription($property->getDescription())
                ->setInputType($property->getInputType());
        }
    }

}